package com.lingxu.api.ztb.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lingxu.api.ztb.mapper.GetTBUnitMapper;
import com.lingxu.api.ztb.model.vo.GetTBUnitVO;
import com.lingxu.api.ztb.service.IGetTBUnitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;
@Slf4j
@Service
public class GetTBUnitServiceImpl implements IGetTBUnitService {

    @Autowired
    private GetTBUnitMapper getTBUnitMapper;

    @Transactional(readOnly = true)
    @Override
    public IPage<GetTBUnitVO> list(GetTBUnitVO getTBUnitVO) {
        GetTBUnitVO id = getTBUnitMapper.getId(getTBUnitVO.getSectionName());
        getTBUnitVO.setPARAGRAPHID(id.getPARAGRAPHID());
        Page<GetTBUnitVO> page = new Page<>(getTBUnitVO.getPageNo(), getTBUnitVO.getPageSize());
        IPage<GetTBUnitVO> unitName = getTBUnitMapper.getUnitName(page, getTBUnitVO);
        return unitName;
    }
}
